/*
 * Copyright 2002-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.web.context;

import javax.servlet.ServletContext;

import org.springframework.context.ApplicationContext;
import org.springframework.lang.Nullable;

/**
 * Interface to provide configuration for a web application. This is read-only while
 * the application is running, but may be reloaded if the implementation supports this.
 *
 * <p>This interface adds a {@code getServletContext()} method to the generic
 * ApplicationContext interface, and defines a well-known application attribute name
 * that the root context must be bound to in the bootstrap process.
 *
 * <p>Like generic application contexts, web application contexts are hierarchical.
 * There is a single root context per application, while each servlet in the application
 * (including a dispatcher servlet in the MVC framework) has its own child context.
 *
 * <p>In addition to standard application context lifecycle capabilities,
 * WebApplicationContext implementations need to detect {@link ServletContextAware}
 * beans and invoke the {@code setServletContext} method accordingly.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @see ServletContextAware#setServletContext
 * @since January 19, 2001
 */
/*xxx: web环境的应用上下文抽象*/
public interface WebApplicationContext extends ApplicationContext {

    /**
     * Context attribute to bind root WebApplicationContext to on successful startup.
     * <p>Note: If the startup of the root context fails, this attribute can contain
     * an exception or error as value. Use WebApplicationContextUtils for convenient
     * lookup of the root WebApplicationContext.
     *
     * @see org.springframework.web.context.support.WebApplicationContextUtils#getWebApplicationContext
     * @see org.springframework.web.context.support.WebApplicationContextUtils#getRequiredWebApplicationContext
     */
    /*xxx:  成功启动时要将根WebApplicationContext绑定到的上下文属性*/
    String ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE = WebApplicationContext.class.getName() + ".ROOT";

    /**
     * Scope identifier for request scope: "request".
     * Supported in addition to the standard scopes "singleton" and "prototype".
     */
    /*xxx: 除了标准作用域“singleton”和“prototype”外，还支持request作用域的标识符*/
    String SCOPE_REQUEST = "request";

    /**
     * Scope identifier for session scope: "session".
     * Supported in addition to the standard scopes "singleton" and "prototype".
     */
    /*xxx: 除了标准作用域“singleton”和“prototype”外，还支持session作用域的标识符*/
    String SCOPE_SESSION = "session";

    /**
     * Scope identifier for the global web application scope: "application".
     * Supported in addition to the standard scopes "singleton" and "prototype".
     */
    /*xxx: 除了标准作用域“singleton”和“prototype”外，还支持application作用域的标识符*/
    String SCOPE_APPLICATION = "application";

    /**
     * Name of the ServletContext environment bean in the factory.
     *
     * @see ServletContext
     */
    /*xxx: 容器中，servlet上下文环境bean的名称*/
    String SERVLET_CONTEXT_BEAN_NAME = "servletContext";

    /**
     * Name of the ServletContext init-params environment bean in the factory.
     * <p>Note: Possibly merged with ServletConfig parameters.
     * ServletConfig parameters override ServletContext parameters of the same name.
     *
     * @see ServletContext#getInitParameterNames()
     * @see ServletContext#getInitParameter(String)
     * @see javax.servlet.ServletConfig#getInitParameterNames()
     * @see javax.servlet.ServletConfig#getInitParameter(String)
     */
    /*xxx: 容器中，servlet上下文的初始化参数的名称*/
    String CONTEXT_PARAMETERS_BEAN_NAME = "contextParameters";

    /**
     * Name of the ServletContext attributes environment bean in the factory.
     *
     * @see ServletContext#getAttributeNames()
     * @see ServletContext#getAttribute(String)
     */
    /*xxx: 容器中，servlet上下文的参数的名称*/
    String CONTEXT_ATTRIBUTES_BEAN_NAME = "contextAttributes";


    /**
     * Return the standard Servlet API ServletContext for this application.
     */
    @Nullable
    /*xxx: 获取标准Servlet API规范的 servlet上下文*/
    ServletContext getServletContext();

}
